let path = require("path")
// let fs = require("fs")
let os = require("os")
let redis = require("./redis")
module.exports = appInfo => {
	let sequelize = {
		dialect: "mysql", // support: mysql, mariadb, postgres, mssql
		database: "mserver",
		host: "127.0.0.1",
		port: "3306",
		username: "root",
		password: "root",
		timezone: "+08:00",
		logging() {}
	}
	let imgBase = "/public/png/"
	let serverConfig = {
		authKey: "aq8spp1d4cu",
		imgBase,
		host: "https://api.miaohuanxi.com/",
		tokenTime: 60000,
		uploadPath: "",
		imgServerPath: path.join(os.homedir(), "./vhost/static-web/"),
		imgServer: "http://static-wx.miaohuanxi.com"
	}
	serverConfig.uploadPath = path.resolve(path.join(serverConfig.imgServerPath, imgBase))
	console.log("上传目录" + path.join(os.homedir(), "/vhost/stati-web/", imgBase))
	/* 	if (!fs.existsSync(serverConfig.uploadPath)) {
			throw new Error("上传目录不存在")
		} */
	let cluster = {
		listen: {
			port: 7003,
			hostname: "127.0.0.1"
		}
	}

	let cors = {
		allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH",
		credentials: true
	}
	const config = exports = {sequelize, cluster, cors, serverConfig, redis}
	return config
}